﻿using Microsoft.AspNetCore.Mvc;
using TR.AppService.AppService.Bs_warehouse;
using TR.Domain.Entity;
using TR.Domain.Entity.BsItemType;
using TR.Domain.Repository.sqlDto;

namespace TR.WebApi.Controllers.bs_warehouseControllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class bs_warehouseControllers : Controller
    {
        private readonly IBs_warehouseService bs_WarehouseService;
        public bs_warehouseControllers(IBs_warehouseService bs_WarehouseService)
        {
            this.bs_WarehouseService = bs_WarehouseService;
        }

        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="currentPage"></param>
        /// <param name="str"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<FenYe<bs_WareHouse>> bs_Item_FenYe(int pageSize, int currentPage, string str)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            return await bs_WarehouseService.bs_Item_FenYe(pageSize, currentPage, str);
        }
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="addItemCsDto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<bool> ItemAdd(bs_WareHouse bs_Ware)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            Console.WriteLine("ItemAdd--->");
            return await bs_WarehouseService.ItemAdd(bs_Ware);
        }
        //逻辑删除
        [HttpPost]
        public async Task<bool> ItemUDelect(int id)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            Console.WriteLine("ItemUDelect--->");
            return await bs_WarehouseService.ItemDelect(id);
        }
        [HttpGet]
        public async Task<bs_WareHouse> ItemSelect(int id)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            Console.WriteLine("ItemSelect--->");
            return await bs_WarehouseService.ItemSelete(id);
        }

        [HttpPut]
        public async Task<bool> KWUpdate(List<int> id, string warecode)
        {
            return await bs_WarehouseService.KWUpdate(id, warecode);
        }
        [HttpGet]
        public Task<bs_WareHouse> ItemSelectCode(string ware_code)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            Console.WriteLine("ItemSelectCode--->");
            return bs_WarehouseService.ItemSelectCode(ware_code);
        }
        [HttpPost]
        public async Task<bool> ItemUpdate(bs_WareHouse uid)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            Console.WriteLine("ItemTypeUpdate--->");
            return await bs_WarehouseService.ItemUpdate(uid);
        }
    }
}
